package com.leen.news.controller;

import com.leen.common.vo.ResponseVO;
import com.leen.common.vo.ResultVO;
import com.leen.news.dto.YxSystemConfigDTO;
import com.leen.news.entity.YxSystemConfig;
import com.leen.news.service.YxSystemConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "/news/ysconfig")
@Api(tags = "配置表")
public class YxSystemConfigController {

    @Autowired
    private YxSystemConfigService yxSystemConfigService;

    @GetMapping(value = "/data")
    @ApiOperation(value = "分页查询")
    public ResultVO<ResponseVO>  search(YxSystemConfigDTO yxSystemConfigDTO){
        ResponseVO search = this.yxSystemConfigService.search(yxSystemConfigDTO);
        return ResultVO.success(search);
    }

    @PostMapping(value = "/add")
    @ApiOperation(value = "添加配置")
    public ResultVO<String> insert(@RequestBody @Valid YxSystemConfig yxSystemConfig){
        return this.yxSystemConfigService.insert(yxSystemConfig);
    }

    @PostMapping(value = "/update")
    @ApiOperation(value = "修改配置")
    public ResultVO<String> update(@RequestBody @Valid YxSystemConfig yxSystemConfig){
        return this.yxSystemConfigService.updateById(yxSystemConfig);
    }
}
